package com.woniuxy.merchant.util;

import com.woniu.commons.util.JwtUtil;
import com.woniu.commons.util.RedisKey;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class MerchartTokenUtil {

    @Resource
    private JwtUtil jwtUtil;

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    public Integer getAdminId(String token){
        Integer AdminId = (Integer) jwtUtil.parseToken(stringRedisTemplate.opsForValue().get(RedisKey.ADMIN_REFRESH_TOKEN_KEY(token))).get("id");
        return AdminId;
    }

    public Integer getUserId(String token){
        Integer userId = (Integer) jwtUtil.parseToken(stringRedisTemplate.opsForValue().get(RedisKey.USER_REFRESH_TOKEN_KEY(token))).get("id");
        return userId;
    }
}
